class ListNode(object):
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
class Solution(object):
    def pairSum(self, head):
        nums = []
        node = head
        while node:
            nums.append(node.val)
            node = node.next
        max_val = 0
        for i in range(len(nums) // 2):
            max_val = max(max_val, nums[i] + nums[- 1 - i])
        return max_val